package com.hongxun.entity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.hongxun.budget.R;
import com.hongxun.budget.ui.activity.sg.ConstructionActivity;
import com.hongxun.budget.ui.activity.tk.MaterialModelActivity;
import com.hongxun.budget.ui.activity.tk.ProjectActivity;
import com.hongxun.budget.ui.activity.tk.ProjectCreateActivity;
import com.hongxun.budget.ui.activity.tk.ProjectListActivity;
import com.hongxun.budget.ui.activity.ys.CheckActivity;
import com.hongxun.budget.ui.activity.ys.CheckCreateActivity;
import com.hongxun.budget.ui.activity.ys.CheckListActivity;
import com.hongxun.budget.utils.SPUtils;
import com.hongxun.budget.utils.SgStrKey;
import com.hongxun.budget.utils.T;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by admin on 2018/5/15.
 */

public class HomeItem {

    private int imgRes;
    private String title;
    private View.OnClickListener listener;

    public HomeItem(int imgRes, String title, View.OnClickListener listener) {
        this.imgRes = imgRes;
        this.listener = listener;
        this.title = title;
    }

    public HomeItem() {
    }

    public int getImgRes() {
        return imgRes;
    }

    public void setImgRes(int imgRes) {
        this.imgRes = imgRes;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public View.OnClickListener getListener() {
        return listener;
    }

    public void setListener(View.OnClickListener listener) {
        this.listener = listener;
    }

    public static List<HomeItem> getHomeItem(final Context context) {
        List<HomeItem> list = new ArrayList<>();
        list.add(new HomeItem(R.mipmap.icon_1, "创建项目", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, ProjectCreateActivity.class));
            }
        }));
        list.add(new HomeItem(R.mipmap.icon_2, "项目踏勘", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String guid = (String) SPUtils.get(context, "project_guid", "");
                if (TextUtils.isEmpty(guid)) {
                    T.showLong(context, "请先选择项目");
                    return;
                }
                context.startActivity(new Intent(context, ProjectActivity.class));
            }
        }));
        list.add(new HomeItem(R.mipmap.icon_3, "项目列表", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, ProjectListActivity.class));

            }
        }));
        list.add(new HomeItem(R.mipmap.icon_4, "材料模块", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, MaterialModelActivity.class));
            }
        }));
        return list;
    }

    public static List<HomeItem> getHomeItem2(final Context context) {
        List<HomeItem> list = new ArrayList<>();
        list.add(new HomeItem(R.mipmap.ty_xmjd, "项目进度", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, ConstructionActivity.class)
                        .putExtra("tabName", SgStrKey.xmjd));
            }
        }));
        list.add(new HomeItem(R.mipmap.ty_cldc, "材料到场", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, ConstructionActivity.class)
                        .putExtra("tabName", SgStrKey.cldc));
            }
        }));
        list.add(new HomeItem(R.mipmap.ty_zjjc, "中间检查", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, ConstructionActivity.class)
                        .putExtra("tabName", SgStrKey.zjjc));
            }
        }));
        return list;
    }

    public static List<HomeItem> getHomeItem3(final Context context) {
        List<HomeItem> list = new ArrayList<>();
        list.add(new HomeItem(R.mipmap.icon_1, "创建项目", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, CheckCreateActivity.class));
            }
        }));
        list.add(new HomeItem(R.mipmap.icon_ys, "现场验收", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String guid = (String) SPUtils.get(context, "project_ys_guid", "");
                if (TextUtils.isEmpty(guid)) {
                    T.showLong(context, "请先选择项目");
                    return;
                }
                context.startActivity(new Intent(context, CheckActivity.class));
            }
        }));
        list.add(new HomeItem(R.mipmap.icon_yslb, "验收列表", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, CheckListActivity.class));
            }
        }));
        return list;
    }
}
